package com.company.ddd.infrastructure.persistence.hibernate;

import com.company.ddd.domain.model.user.IUserRepository;
import com.company.ddd.domain.model.user.User;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Repository;

/**
 * =================================
 * <p>
 * Created by cjj on 18-11-25.
 * <p>
 * 描述: 用户仓储
 */

@Repository
@DependsOn(value = "sessionFactory")
public class UserRepository extends HibernateRepository implements IUserRepository {


    public User find(final String code) {
        return (User) getSession().
                createQuery("from User where code = :code").
                setParameter("code", code).
                uniqueResult();
    }

    @Override
    public void save(User user) {
        save(user);
    }


}
